package com.example.administrator.pathdemo;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PointF;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018\3\15 0015.
 */

public class PathDemo1 extends View {




    private Point controlPoint = new Point(200, 200);



    Path mPath = new Path();
    private Paint mPaint;




    public PathDemo1(@NonNull Context context) {
        super(context);
        initPaint();
    }

    public PathDemo1(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initPaint();
    }

    public PathDemo1(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initPaint();
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public PathDemo1(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initPaint();
    }


    private void initPaint() {
        mPaint = new Paint();
        mPaint.setColor(Color.BLACK);
        mPaint.setStrokeWidth(8);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setTextSize(60);



    }

    private void initmPoints() {
//
//        Point point1 = new Point(166,860);
//        Point point2 = new Point(260,826);
//        Point point3 = new Point(266,794);
//        Point point4 = new Point(351,705);
//        Point point5 = new Point(322,655);
//        Point point9 = new Point(447,607);
//        Point point10 = new Point(553,632);
//        Point point11 = new Point(526,623);
//        Point point12 = new Point(633,640);
//        Point point13 = new Point(633,651);
//        Point point14 = new Point(396,717);
//        Point point15 = new Point(429,688);
//        Point point16 = new Point(429,674);
//        Point point17 = new Point(368,660);
//        Point point18 = new Point(390,668);
//        Point point19 = new Point(305,796);
//        Point point20 = new Point(326,842);
//        Point point21 = new Point(277,847);
//        Point point22 = new Point(218,866);
//        Point point23 = new Point(182,884);

//        mPoints.add(point1);
//        mPoints.add(point2);
//        mPoints.add(point3);
//        mPoints.add(point4);
//        mPoints.add(point5);
//        mPoints.add(point9);
//        mPoints.add(point10);
//        mPoints.add(point11);
//        mPoints.add(point12);
//        mPoints.add(point13);
//        mPoints.add(point14);
//        mPoints.add(point15);
//        mPoints.add(point16);
//        mPoints.add(point17);
//        mPoints.add(point18);
//        mPoints.add(point19);
//        mPoints.add(point20);
//        mPoints.add(point21);
//        mPoints.add(point22);
//        mPoints.add(point23);


    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);


        super.onDraw(canvas);
        mPaint.setStrokeWidth(10);
        mPaint.setColor(Color.BLACK);
        // 重置路径
        mPath.reset();


        mPath.moveTo(8,365);
        mPath.cubicTo(112,328,103,286,121,270);
//        mPath.quadTo(111,317,113,280);
        mPath.lineTo(190,204);


        canvas.drawPath(mPath,mPaint);




    }



}
